<template>
  <a-card :bordered="false" :bodyStyle="bodyStyle" style="height: 100%">
    <redirect :func="func" :id="id" :code="formCode" :fks="fks" @close="close"
              @refreshParent="refreshParent" :ignoreSec="ignoreSec"
              @setTitle="setTitle" :parentValue="parentValue"
              @setModelType="setModelType"
              v-on="$listeners" v-bind="$attrs" :showCloseBut="false" :processInstanceName="title"></redirect>
  </a-card>
</template>

<script>

import Redirect from './Redirect'

export default {
  name: 'RedirectModal',
  components: {
    Redirect
  },
  props: {
    ignoreSec: Boolean,
    func: String,
    formCode: String,
    id: String,
    fks: {
      type: Array,
      default: () => []
    },
    parentValue: {
      type: Object,
      default: () => {
      }
    },
    stores: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  data() {
    return {
      title: this.$t('m.bpm.common.bpmPage'),
      modelType: null,
    }
  },
  inject: ['closeCurrent', 'removeCache'],
  created() {
    this.$route.meta.title = this.title
  },
  computed: {
    bodyStyle() {
      const style = {};
      if (this.modelType === 'layout') {
        style.padding = 0;
        style.margin = 0;
        style.height = '100%';
      }
      return style;
    },
  },
  methods: {
    handleCancel() {
      this.closeCurrent()
    },
    //关闭页面
    close() {
      this.handleCancel()
    },
    //刷新父页面
    refreshParent() {
      // 刷新父页面
      this.removeCache(this.$route.meta.parentFullPath)
    },
    //设置标题
    setTitle(title) {
      this.title = title
      this.$route.meta.title = title
    },
    // 设置模型类型，组合页面或者表单页面
    setModelType(modelType) {
      this.modelType = modelType
    },
  }
}
</script>
